import java.io.PrintStream;
import java.util.Vector;
import java.util.ListIterator;

public class DutyFree {

	//Message parsers can expect this number of fields for Main DUTYFREE Info
  public static final int NUM_MANDATORY_FIELDS = 5; 
	
	private int m_Ref = 0;				/* Mandatory */
	private String m_Name;				/* Mandatory */
	private String m_Location;		/* Mandatory */
	private String m_Product;				/* Mandatory */
	private String m_Price;				/* Mandatory */
	private String m_MapFile;
	private Vector<String> m_OffServices;

	public DutyFree(int ref, String name, String location, String product, String price, String mapFile){
		m_Ref = ref;
		m_Name = name;
		m_Location = location;
		m_Product = product;
		m_Price = price;
		m_MapFile = mapFile;
		m_OffServices = new Vector<String>();
	}

	public DutyFree(int ref, String name, String location, String product, String price){
		m_Ref = ref;
		m_Name = name;
		m_Location = location;
		m_Product = product;
		m_Price = price;
		m_OffServices = new Vector<String>();
	}
	synchronized public String getMainInfoAsDelimString(String delim){
		StringBuilder draftResp = new StringBuilder();
		draftResp.append(m_Ref + delim);
		draftResp.append(m_Name + delim);
		draftResp.append(m_Location + delim);

		if (m_Product != null)
			draftResp.append(m_Product + delim);
		else
			draftResp.append('\u0020' + delim);

		if (m_Price != null)
			draftResp.append(m_Price + delim);
		else
			draftResp.append('\u0020' + delim);
		
		return draftResp.toString();
	}
	
	public int getRef (){
		return m_Ref;
	}
	
	public String getName(){
		return m_Name;
	}
	
	public String getLocation(){
		return m_Location;
	}
	
	public String getPhone(){
		return m_Product;
	}
	
	public String getEmail(){
		return m_Price;
	}
	
	public Vector<String> getOffServices(){
		return m_OffServices;
	}

  public void addDUTYFREEService(String srvc){
  	m_OffServices.add(srvc);
  }

  synchronized public String getOffServicesDelimString(String delim){
  	StringBuilder draftResp = new StringBuilder();
  	ListIterator<String> iter = m_OffServices.listIterator();
  	
  	while (iter.hasNext())
  		draftResp.append(iter.next() + delim);
  	
  	return draftResp.toString();
  }

	public void printMainInfoToConsole() {
		PrintStream out = System.out;
		
		out.println();
		out.println(m_Name);
		out.println("Location: " + m_Location);
		out.println("Special offer: " + m_Price);
		out.println("ProductID: " + m_Product);
	
		out.println();
	}
}


